﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FRW.Common.Extensions;

namespace Money.Configruation
{
    /// <summary>
    /// 
    /// </summary>
    public class UiConfigurationManager
    {
        private class ConfigurationItem
        {
            public object Item { get; set; }
            public ObjectType Type { get; set; }
        }

        List<ConfigurationItem> _configurationItems = new List<ConfigurationItem>();

        private enum ObjectType
        {
            DataGridItem,
            FormItem,
            NotSupported
        }

        public bool Register(object guiObject)
        {
            ObjectType type = ObjectType.NotSupported;

            TypeSwitch.Do(guiObject,
                TypeSwitch.Case<DataGridView>(() => type = ObjectType.DataGridItem),
                TypeSwitch.Default(() => type = ObjectType.NotSupported));

            if (type != null)
            {
                ConfigurationItem item = new ConfigurationItem();
                item.Item = guiObject;
                item.Type = type;

                // TODO we need to check that the item is not already in the list, how?, name?
                _configurationItems.Add(item);
            }

            switch (type)
            {
                case ObjectType.DataGridItem:
                    DataGridView dataGrid = guiObject as DataGridView;
                    break;
            }

            return true;
        }
    }
}
